package com.nothingboard.module.member.service.impl;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nothingboard.common.data.request.GlobalVariables;
import com.nothingboard.module.member.dao.MemberDao;
import com.nothingboard.module.member.model.MemberDto;
import com.nothingboard.module.member.model.MemberLogonDto;
import com.nothingboard.module.member.model.MemberSearchDto;
import com.nothingboard.module.member.service.MemberService;

@Service("memberService")
public class MemberServiceImpl implements MemberService {
	
	@Autowired
	private MemberDao memberDao;
	
	public boolean getLoginCheck(MemberLogonDto dto, HttpSession session) throws Exception {

		MemberDto memberDto = (MemberDto) memberDao.getMemberByUsrId(dto);
		MemberSearchDto search = null;
		
		if(memberDto != null){
			search = new MemberSearchDto();
			search.setUsrNo(memberDto.getUsrNo());
			memberDto = (MemberDto) memberDao.getMember(search);
			if(memberDto.isAdminGrant()){
				session.setAttribute(GlobalVariables.SESSION, memberDto);
				return true;
			}
		}
		return false;
		
	}

}
